<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page isELIgnored='false'%>
<script language="JavaScript" type="text/javascript">

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}

function filterAction()
{
   window.location.href = "<%= request.getParameter("file") %>" +
    "?anno1Id=" + document.filterForm.anno1Selector.value +
    "&anno2Id=" + document.filterForm.anno2Selector.value;  
}
 
function initFilter()
{
  var anno1Param = getURLParam("anno1Id");
  var anno2Param = getURLParam("anno2Id");

  for (i = 0; i < document.filterForm.anno1Selector.length; i++)
  {
    var option = document.filterForm.anno1Selector.options[i];
    if (option.value == anno1Param)
    {      
    	  document.filterForm.anno1Selector.selectedIndex = option.index;
    } else {
    	  document.filterForm.anno1Selector.selectedIndex = 0;
    }
  }

  for (i = 0; i < document.filterForm.anno2Selector.length; i++)
  {
    var option = document.filterForm.anno2Selector.options[i];
    if (option.value == anno2Param)
    {      
    	  document.filterForm.anno2Selector.selectedIndex = option.index;
    } else {
    	  document.filterForm.anno2Selector.selectedIndex = 0;
    }
  }  
}
</script>

<form name="filterForm">
  <table>
    <tr><td>
        Annotator 1:
        <select name="anno1Selector">
          <option value='1'>Annotator ID 1</option>
	        <option value='3'>Annotator ID 3</option>
	        <option value='4'>Annotator ID 4</option>
	        <option value='19'>Annotator ID 19</option>
        </select>
   </td>
   <td>
       Annotator 2:
         <select name="anno2Selector">
           <option value='1'>Annotator ID 1</option>
	         <option value='3'>Annotator ID 3</option>
	         <option value='4'>Annotator ID 4</option>
	         <option value='19'>Annotator ID 19</option>
         </select>
    </td>
    <td>
        <input value="Submit" type="button" onClick="filterAction();" /> 
    </td></tr>
  </table>
</form>
